//*********************************************************************
// "Group 3"
// CS 1C
// March 25, 2010
// Group Project: SuperWarehouse
// Due: March 25, 2010
// File name: main.cpp
// This is the driver file
//*********************************************************************

#include <iostream>
#include <iomanip>
#include "Member.h"
#include "MemberList.h"
#include "MemberManager.h"
#include "CheckoutService.h"
#include "Menus.h"
//#include "test.h"


using namespace std;

//*********************************************************************
// Function main
// Preconditions: none
// Postconditions: Some stuff has been done
//*********************************************************************
int main() {
	char buf[1000];
	MemberManager *mgr;

	Splash();

	// Initialize member database
	mgr = MemberManager::instance();
	mgr->setDataFile(CUSTOMERS_DATA_FILE);
	if (!mgr->initialize()) {
		errorMsg("Error initializing data file");
		return 1;
	}
	sprintf(buf, "Member manager initialized with %d members.",
			mgr->getAllMembers()->getNumMembers());
	statusMsg(buf);

	MainMenu();

	if (!mgr->save()) {
		errorMsg("Unable to save members data file");
	} else {
		statusMsg("Members data file saved");
	}

	return 0;

	/*
	//Creates an overloaded object for MemberManager - KZ's comment
	MemberManager *mgr = new MemberManager();
	//This just loads member files from text file - KZ's comment
	mgr->importMembersFromTextFile(string("data/customers.txt"));

	//Assembles a list of members together - KZ's comment
	MemberList *list = mgr->getMembers();

	cout << "---\n";
	//This just keeps track of how many members are in the member list - KZ's comment
	int n = list->getNumMembers();

	//This outputs a list of member info on screen - KZ's comment
	for (int i = 0; i < n; i++) {
		cout << list->retrieveMemberAtIndex(i)->toString() << endl;
	}

	cout << "\n\n---\n\n";
	//Creates a checkout service guy (figuratively speaking) - KZ's comment
	CheckoutService *checker = new CheckoutService(mgr);
	//This processes a daily sales list from file - KZ's comment
	checker->processDailySalesFromFile(string("data/11-05-08.txt"));

	return 0;
	*/
}
